package com.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dao.UserDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@Service
public class UserServiceImplDetail  {//implements UserDetailsService
    @Resource
    private UserDao userDao;
    /*@Override
    public User loadUserByUsername(String username) throws UsernameNotFoundException {
        //查询条件
        QueryWrapper<com.pojo.User> wrapper = new QueryWrapper<com.pojo.User>();
        wrapper.eq("name",username);

        //查询用户
        com.pojo.User user = userDao.selectOne(wrapper);
        if (user == null){
            throw new UsernameNotFoundException("用户名不存在");
        }else {
            Collection<GrantedAuthority> authorities = getAuthority();
            return new User(user.getName(),user.getPassword(),authorities);
        }
    }


    public Collection<GrantedAuthority> getAuthority(){
        List<GrantedAuthority> list = new ArrayList<GrantedAuthority>();

        *//*List<Map<String, Object>> roleList=null;
          for (Map<String, Object> rolemap : roleList ) {
            String rolename = rolemap.get("name").toString();
            list.add(new SimpleGrantedAuthority("ROLE_" + rolename));
        }*//*


        list.add(new SimpleGrantedAuthority("USER"));
        list.add(new SimpleGrantedAuthority("ROLE_ADMIN"));
        list.add(new SimpleGrantedAuthority("ROLE_ROOT"));
        return list;
    }*/
}
